﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ctpDataContext db = new ctpDataContext();
        var data = from p in db.ct_s_profiles
                select p.no;

        foreach (var d in data.Distinct())
        {

            try
            {
                ct_s_profile newp = db.ct_s_profiles.Single(p => p.no == (int)d && p.valid == true);
            }
            catch (Exception e1)
            {
                Response.Write(d.ToString() + "<br>");
                Response.Write("<p>");


                var data1 = from q in db.ct_s_profiles
                            where q.no == (int)d
                            select q;

                foreach (ct_s_profile sp in data1)
                {
                    Response.Write(sp.title.Trim()+ "<br>");


                }

                Response.Write("<p>");


            }
        }

       // this.GridView1.DataSource =data.Distinct();

       // this.DataBind();

        

        //return;

        //ctpDataContext db = new ctpDataContext();

        //var re = from p in db.ct_s_reviews
        //         select p;

        //foreach (ct_s_review r in re)
        //{
        //    try
        //    {

        //        ct_s_profile c = db.ct_s_profiles.Single(p => p.no == r.ct_s_no && p.valid == true);
        //        Response.Write(r.ct_s_no + "=>" + c.ct_no + "<br>");

        //        if (r.is_local)
        //        {
        //            user u1 = db.users.Single(p => p.no == r.create_user_no);
        //            u1.ct_no = c.ct_no;
        //            db.SubmitChanges();
        //        }

        //        //if (r.been_there)
        //        //{
        //        //    r.ct_no = c.ct_no;
        //        //}


        //    }
        //    catch(Exception e1)
        //    {
        //                        Response.Write(r.ct_s_no + "=> error<br>");

        //    }
            
        //}

        //db.SubmitChanges();

        //this.GridView1.DataSource = re;
        //this.DataBind();


    }
}
